<%@page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@taglib uri="TowkerTagLib" prefix="rbac"%>
<%@include file="/commons/include/html_doctype.html"%>
<html>
<head>
	<title>添加</title>
	<%@include file="/commons/include/add.jsp" %>
	<script type="text/javascript">
$(function(){
	jQuery("#dataForm").validate(
	{
		rules: {
			depot_code:{
				required:true
			},
			depot_nane:{
				required:true
			},
			depot_addr:{
				required:true
			},
			co_code:{
				required:true
			}
		},
		messages: {
			depot_code:{
				required:"请填写仓库代码"
			},
			depot_nane:{
				required:"请填写仓库名称"
			},
			depot_addr:{
				required:"请填写仓库地址"
			},
			co_code:{
				required:"请选择所属公司代码"
			}
		},
		submitHandler:function(form)
		{
			$("#co_code").val($('#a_co_code').val());
			jQuery.ajax({
				url : ctx + '/manage/basicData/checkExistsDepotCode.htm',
				type : "POST",
				data : {id:0,depot_code:$('#depot_code').val()},
				dataType : "json",
				success : function(d) {
				if(!d.result)
					jQuery(form).ajaxSubmit(_options);
				else
					alert('仓库代码有重复!');
				},error:function(){
				   alert('后台验证仓库代码出错');
				}
			});
		}
	});
	if($("#co_code").val() != "") {
		$("#a_co_code").hide();
		$("#s_co_code").show();
	} else {
		$("#a_co_code").combobox();
		$("#s_co_code").hide();
	}
});
_callback = function() {
	location.href = ctx + "/manage/basicData/getDepots.htm";
}
validCallBack = function()
{
	//添加页面自定义校验

	return true;
};
	</script>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0" class="listLogo">
	<tr>
		<td class="title">仓库信息添加</td>
		<td>
			<div class="menuTool">
				<a class="save" id="dataFormSave" href="#">保存</a>
				<a class="back" href="getDepots.htm">返回</a>
			</div>
		</td>
	</tr>
</table>
<div class="line"></div>
<form id="dataForm" method="post" action="addDepots2.htm">
<table border="0" cellspacing="1" cellpadding="0" class="listTable">
	<tr>
		<td class="form_title">仓库代码：</td>
		<td class="form_input"><input type="text" id="depot_code" name="depot_code" value="" /></td>
		
		<td class="form_title">仓库名称：</td>
		<td class="form_input"><input type="text" id="depot_nane" name="depot_nane" value="" /></td>
		<td class="form_title">仓库地址：</td>
		<td class="form_input"><input type="text" id="depot_addr" name="depot_addr" value="" /></td>
		
	</tr>
	<tr>
	  <td class="form_title">所属公司代码：</td>
		<td class="form_input">
		<select id="a_co_code" name="a_co_code">
				<option value="" >请选择</option>
				 <c:forEach items="${companiesList}" var="d" varStatus="status">
					<option value="${d.co_code}">${d.co_name }[${d.co_code}]</option>
				</c:forEach>
		</select>
        <span id="s_co_code">${co_code}</span>
		</td>
		<td class="form_title"></td>
		<td class="form_input"></td>
		<td class="form_title"></td>
		<td class="form_input"></td>
	</tr>
</table>
<input type="hidden" name="co_code" id="co_code" value="${co_code}" />
</form>
</body>
</html>
